package com.lyf.scm.job.task;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.lyf.scm.job.config.AbstractSimpleJob;
import com.lyf.scm.job.remote.facade.BigDataSalesPlanFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description:
 *       销售计划同步job
 * @author: haodong
 * @data: 2020/11/2 14:50
 */
@Slf4j
@Component
public class BigDataSalesPlanJob extends AbstractSimpleJob {

    @Value("${elastic.job.BigDataSalesPlanJob.jobName}")
    private String jobName;
    @Value("${elastic.job.BigDataSalesPlanJob.cron}")
    private String cron;
    @Value("${elastic.job.BigDataSalesPlanJob.shardingTotalCount}")
    private Integer shardingTotalCount;
    @Value("${elastic.job.BigDataSalesPlanJob.shardingItemParameters}")
    private String shardingItemParameters;
    @Value("${elastic.job.BigDataSalesPlanJob.failover}")
    private Boolean failover;
    @Value("${elastic.job.BigDataSalesPlanJob.desc}")
    private String desc;

    @Resource
    private BigDataSalesPlanFacade bigDataSalesPlanFacade;

    /**
     * 处理
     *
     * @param shardingContext
     * @return void
     **/
    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("================== 开始执行大数据Job ==================");
        bigDataSalesPlanFacade.handleApiDispatcher();
    }

    @Override
    public void run(String... args) {
        // spring 启动完成后初始化job
        registerSimpleJob(jobName, cron, shardingTotalCount, shardingItemParameters, failover, desc);
    }
}
